<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">

    <title>Wish wall</title>
    <link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../wishwall/css/main.css">
    <!--[if lt IE 9]>
      <script src="lib/html5shiv/html5shiv.min.js"></script>
      <script src="lib/respond/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <!-- header开始 -->
    <%include header.ejs%>
    <!-- header结束 -->

    <!-- intro开始 -->
    <section id="intro">
      <div class="container theme-showcase">
        <div class="jumbotron">
          <div class="row">
            <div class="col-md-7">
              <h1>欢迎大家</h1>
              <h1>来到心愿墙</h1>

              <p>
                <a class="btn btn-primary btn-lg" href="#overview" role="button">了解更多……</a>
              </p>
            </div>
            <div class="col-md-4">
              <form>

                <div class="form-group form-group-lg">
                  <label for="useremail">Email address</label>
                  <input type="email" class="form-control" id="useremail" placeholder="Email"></div>
                <div class="form-group form-group-lg">
                  <label for="userpassword">Password</label>
                  <input type="password" class="form-control" id="userpassword" placeholder="Password"></div>

                <button id="denglu" type="button" class="btn btn-success btn-lg">登录</button>
                <div id="cuowukuang" class="alert alert-warning" role="alert">用户名或邮箱被占用</div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- intro结束 -->


    <!-- footer开始 -->
    <footer id="footer">

    </footer>
    <!-- footer结束 -->

    <script src="lib/jquery/jquery.js"></script>

    <script src="lib/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript">
      $("input").focus(function(){
        $("#cuowukuang").fadeOut();
      });
      $("#denglu").click(function(){
        var a = $("#useremail").val();

        $.post("/dologin",{
        "useremail" : $("#useremail").val(),
        "userpassword" : $("#userpassword").val()
      },function(result){
        if(result=="1"){
          //登录成功
          window.location = "/heart";
        }else if(result=="-1"){
          //没有该用户名
          $("#cuowukuang").fadeIn();
          $("#cuowukuang").html("该邮箱未注册");
        }else if(result=="-2"){
          $("#cuowukuang").fadeIn();
          $("#cuowukuang").html("密码错误");

        }else if(result == "-5"){
          //服务器错误
        }
      });
      });
    </script>
  </body>
</html>